#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   App_WriteDataById_0x2E_test.py
@Time    :   2022/9/14 13:31:28
@Author  :   YangLiang
@Version :   1.0
@Contact :   yangliang@chengtech.com
@License :   (C)Copyright 2022-2025
@Desc    :   None
'''

# here put the import lib
from gettext import find
# from lib2to3.pgen2 import driver
from re import X
from urllib import response
from pytest_assume.plugin import assume

import pytest
import logging
import time
import requests
from sympy import I
# from sympy import assuming
from commDriver.TS_CAN import *
import allure
import sys
from collections.abc import Iterable

from sqlalchemy import false
sys.dont_write_bytecode = True
import Set_up


class Test_DTCSnapshotRecordNUM_phy(object):

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_01_Default_Phy(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x01]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDS', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_01_Extended_Phy(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x01]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDS', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber, dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_02_Default_Phy(self, action,  Driver, dtcNumber, dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x02]
      resp = [0x7F, 0X19,0x31]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_02")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDS', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber, dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_02_Extended_Phy(self, action,  Driver, dtcNumber, dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x02]
      resp = [0x7F, 0X19,0x31]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_02")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDS', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record 03 by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_03_Default_Phy(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x03]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDS', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record 03 by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_03_Extended_Phy(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x03]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDS', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record 04 by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_04_Default_Phy(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x04]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDS', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record 04 by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_04_Extended_Phy(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0x04]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDS', 'ClearFault')


   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_FF_Default_Phy(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0xFF]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      time.sleep(0.5)
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_FF")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDS', 'ClearFault')


   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_FF_Extended_Phy(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0xFF]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_FF")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDS', 'ClearFault')

   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 1 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC1_Defaul_Phy(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep)

      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2E], 0, iStep) 

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x01, 0x00], 0, iStep)
     
      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x28,0x01] + [i+1], 0, iStep)

      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep)

      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2E], 0, iStep) 

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x01, 0x00], 0, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep)

   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 1 in extended session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC1_Extended_Phy(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 3, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep)

      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2E], 0, iStep) 

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x01, 0x00], 3, iStep)
     
      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x28,0x01] + [i+1], 3, iStep)

      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep)

      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2E], 0, iStep) 

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x01, 0x00], 3, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep)

   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 1 AgingCounter40 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC1_AgingCounter40_Defaul_Phy(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep)

      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2E], 0, iStep) 

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x01, 0x00], 0, iStep)
     
      for i in range(40):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         if i > 38:
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x20], 0, iStep)
         else:
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x28,0x01] + [i+1], 0, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep)

   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 3 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC3_Defaul_Phy(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep)
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2E, 0x03, 0x00], 0, iStep)

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x03, 0x01], 0, iStep)


      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x28,0x03] + [i+2], 0, iStep)

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2F,0x03,0x05], 0, iStep)
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2E,0x03,0x05], 0, iStep)

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2C,0x03,0x06], 0, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep)

   
   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 3 in extended session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC3_Extended_Phy(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 3, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep)
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2E, 0x03, 0x00], 0, iStep)

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x03, 0x01], 3, iStep)


      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x28,0x03] + [i+2], 3, iStep)

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2F,0x03,0x05], 3, iStep)
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2E,0x03,0x05], 0, iStep)

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2C,0x03,0x06], 3, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep)
   
   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 3 AgingCounter40 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC3_AgingCounter40_Defaul_Phy(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep)
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2E, 0x03, 0x00], 0, iStep)

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x03, 0x01], 0, iStep)


      for i in range(42):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         if i > 38:
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x20], 0, iStep)
         else:
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x28,0x03] + [i+2], 0, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep)

   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 4 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC4_Defaul_Phy(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04, 0x00], 0, iStep)
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         # 设置电压为8v,生成低压故障
         iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04] + [i + 1], 0, iStep)
         iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      for i in range(2):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16], 0, iStep)
         with assume: assert uds_resp[-1] == 0x04

      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep)


   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 4 in extended session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC4_Extended_Phy(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x00], 3, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04, 0x00], 0, iStep)
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         # 设置电压为8v,生成低压故障
         iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04] + [i + 1], 3, iStep)
         iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      for i in range(2):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16], 3, iStep)
         with assume: assert uds_resp[-1] == 0x04

      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep)
   
   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 4 AgingCounter40 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC4_AgingCounter40_Defaul_Phy(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04, 0x00], 0, iStep)
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      for i in range(41):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         if i > 39:
            iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x00], 0, iStep)
            iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)
         else:
            # 设置电压为8v,生成低压故障
            iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04] + [i +1], 0, iStep)
            iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep)


class Test_DTCSnapshotRecordNUM_Fun(object):

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_01_Default_Fun(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x01]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDSFun', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_01_Extended_Fun(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x01]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber, dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_02_Default_Fun(self, action,  Driver, dtcNumber, dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x02]
      resp = [0x7F, 0X19,0x31]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_02")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDSFun', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber, dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_02_Extended_Fun(self, action,  Driver, dtcNumber, dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x02]
      resp = [0x7F, 0X19,0x31]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_02")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record 03 by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_03_Default_Fun(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x03]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDSFun', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record 03 by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_03_Extended_Fun(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x03]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record 04 by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_04_Default_Fun(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x04]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDSFun', 'ClearFault')

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record 04 by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_04_Extended_Fun(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0x04]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun', 'ClearFault')


   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_FF_Default_Fun(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0xFF]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      time.sleep(0.5)
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_FF")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDSFun', 'ClearFault')


   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_FF_Extended_Fun(self, action,  Driver, dtcNumber,dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0xFF]
      if dtcNumber == [0xD3,0x05,0x55] or dtcNumber == [0xD3,0x05,0x56]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_FF")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun', 'ClearFault')

   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 1 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC1_Defaul_Fun(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep, False, 'UDSFun', 'noClearFault')

      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2E], 0, iStep, False, 'UDSFun', 'noClearFault')

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x01, 0x00], 0, iStep, False, 'UDSFun', 'noClearFault')
     
      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x28,0x01] + [i+1], 0, iStep, False, 'UDSFun', 'noClearFault')

      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep, False, 'UDSFun', 'noClearFault')

      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2E], 0, iStep, False, 'UDSFun', 'noClearFault')

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x01, 0x00], 0, iStep, False, 'UDSFun', 'noClearFault')
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun', 'noClearFault')
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep, False, 'UDSFun', 'noClearFault')

   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 1 in extended session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC1_Extended_Fun(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 3, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep, False, 'UDSFun', 'noClearFault')

      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2E], 0, iStep, False, 'UDSFun', 'noClearFault') 

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x01, 0x00], 3, iStep, False, 'UDSFun', 'noClearFault')
     
      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x28,0x01] + [i+1], 3, iStep, False, 'UDSFun', 'noClearFault')

      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep, False, 'UDSFun', 'noClearFault')

      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2E], 0, iStep, False, 'UDSFun', 'noClearFault')

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x01, 0x00], 3, iStep, False, 'UDSFun', 'noClearFault')
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun', 'noClearFault')
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep, False, 'UDSFun', 'noClearFault')

   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 1 AgingCounter40 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC1_AgingCounter40_Defaul_Fun(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep, False, 'UDSFun', 'noClearFault')

      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2E], 0, iStep, False, 'UDSFun', 'noClearFault') 

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x01, 0x00], 0, iStep, False, 'UDSFun', 'noClearFault')
     
      for i in range(40):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         if i > 38:
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x20], 0, iStep, False, 'UDSFun', 'noClearFault')
         else:
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x28,0x01] + [i+1], 0, iStep, False, 'UDSFun', 'noClearFault')
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun', 'noClearFault')
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x01], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep, False, 'UDSFun', 'noClearFault')

   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 3 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC3_Defaul_Fun(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep, False, 'UDSFun', 'noClearFault')
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2E, 0x03, 0x00], 0, iStep, False, 'UDSFun', 'noClearFault')

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x03, 0x01], 0, iStep, False, 'UDSFun', 'noClearFault')


      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x28,0x03] + [i+2], 0, iStep, False, 'UDSFun', 'noClearFault')

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2F,0x03,0x05], 0, iStep, False, 'UDSFun', 'noClearFault')
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2E,0x03,0x05], 0, iStep, False, 'UDSFun', 'noClearFault')

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2C,0x03,0x06], 0, iStep, False, 'UDSFun', 'noClearFault')
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun', 'noClearFault')
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep, False, 'UDSFun', 'noClearFault')

   
   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 3 in extended session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC3_Extended_Fun(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 3, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep, False, 'UDSFun', 'noClearFault')
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2E, 0x03, 0x00], 0, iStep, False, 'UDSFun', 'noClearFault')

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x03, 0x01], 3, iStep, False, 'UDSFun', 'noClearFault')


      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x28,0x03] + [i+2], 3, iStep, False, 'UDSFun', 'noClearFault')

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2F,0x03,0x05], 3, iStep, False, 'UDSFun', 'noClearFault')
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2E,0x03,0x05], 0, iStep, False, 'UDSFun', 'noClearFault')

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2C,0x03,0x06], 3, iStep, False, 'UDSFun', 'noClearFault')
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun', 'noClearFault')
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep, False, 'UDSFun', 'noClearFault')
   
   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 3 AgingCounter40 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC3_AgingCounter40_Defaul_Fun(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2F], 0, iStep, False, 'UDSFun', 'noClearFault')
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2E, 0x03, 0x00], 0, iStep, False, 'UDSFun', 'noClearFault')

      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x2C, 0x03, 0x01], 0, iStep, False, 'UDSFun', 'noClearFault')


      for i in range(42):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         if i > 38:
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x20], 0, iStep, False, 'UDSFun', 'noClearFault')
         else:
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x28,0x03] + [i+2], 0, iStep, False, 'UDSFun', 'noClearFault')
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun', 'noClearFault')
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep, False, 'UDSFun', 'noClearFault')

   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 4 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC4_Defaul_Fun(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04, 0x00], 0, iStep, False, 'UDSFun', 'noClearFault')
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         # 设置电压为8v,生成低压故障
         iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04] + [i + 1], 0, iStep, False, 'UDSFun', 'noClearFault')
         iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      for i in range(2):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16], 0, iStep, False, 'UDSFun', 'noClearFault')
         with assume: assert uds_resp[-1] == 0x04

      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun', 'noClearFault')
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep, False, 'UDSFun', 'noClearFault')


   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 4 in extended session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC4_Extended_Fun(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x00], 3, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04, 0x00], 0, iStep, False, 'UDSFun', 'noClearFault')
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      for i in range(3):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         # 设置电压为8v,生成低压故障
         iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04] + [i + 1], 3, iStep, False, 'UDSFun', 'noClearFault')
         iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      for i in range(2):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16], 3, iStep, False, 'UDSFun', 'noClearFault')
         with assume: assert uds_resp[-1] == 0x04

      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun', 'noClearFault')
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep, False, 'UDSFun', 'noClearFault')
   
   @allure.severity('normal')
   @allure.description('Test DTC occurrence counte 4 AgingCounter40 in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_OCC4_AgingCounter40_Defaul_Fun(self, action,  Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x00], 1, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电压为8v,生成低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04, 0x00], 0, iStep, False, 'UDSFun', 'noClearFault')
      # 设置电压为12v,恢复低压故障
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      for i in range(41):
         # ECU下电再次上电
         iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
         if i > 39:
            iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x00], 0, iStep, False, 'UDSFun', 'noClearFault')
            iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)
         else:
            # 设置电压为8v,生成低压故障
            iStep = Driver['CAN'].SetVolt(Driver, 8, 2, iStep)
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x04], [0x59,0x06,0xF0,0x03,0x16,0x2F, 0x04] + [i +1], 0, iStep, False, 'UDSFun', 'noClearFault')
            iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun', 'noClearFault')
      time.sleep(2)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xF0,0x03,0x16,0x03], [0x59,0x06,0xF0,0x03,0x16,0x00], 0, iStep, False, 'UDSFun', 'noClearFault')


